home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / langs / forst.zoo / forst / src / strtfin.s < prev    next >
Encoding:
Text File  |  1990-12-10  |  2.0 KB  |  86 lines

  1. ; STRTFIN.S: starting and finishing routines for ForST
  2. ; Copyright <c> John Redmond, 1989, 1990
  3. ; Public domain for non-commercial use.
  4. ;
  5. init:    bsr    _decimal    ;decimal arithmetic
  6.     lea    dest,a0
  7.     move.l    #1,(a0)        ;console output
  8.     bsr    clrbuffs    ;and input
  9.     lea    iostring,a0
  10.     push    a0
  11.     bsr    _string         ;configure screen behaviour
  12.     rts
  13. ;
  14. setup:    move.l    4(a7),a5
  15.     lea    index,a4    ;get base address pointer
  16.     move.l    $c(a5),d0    ;code size
  17.     move.l    d0,2(a4)
  18.     move.l    $14(a5),d1    ;data size
  19.     move.l    d1,6(a4)
  20.     add.l    d1,d0
  21.     move.l    $1c(a5),d1    ;bss size
  22.     move.l    d1,10(a4)
  23.     add.l    d1,d0
  24.     add.l    #$100,d0    ;size of base page
  25.     andi.b    #$fe,d0        ;align
  26.     lea    (a5,d0.l),a7
  27.     suba.l    heads(pc),a7
  28.     move.l    d0,-(a7)    ;length of block
  29.     move.l    a5,-(a7)    ;start of block
  30.     clr.w    -(a7)
  31.     move.w    #$4a,-(a7)    ;setblock
  32.     trap    #1
  33.     add.l    #12,a7
  34.     move.l    a7,a6
  35.     suba.l    rstck(pc),a6
  36.     lea    stack,a0
  37.     move.l    a7,(a0)        ;save system stack pointer
  38.     lea    dstack,a0
  39.     move.l    a6,(a0)        ;and data stack pointer
  40.     lea    origin,a0
  41.     move.l    a4,(a0)        ;formal origin of code
  42.     move.l    a4,a5        ;and base pointer
  43.     bsr    headersup    ;headers into place above stacks
  44.     bra    cold
  45. ;
  46. clrbuffs: bsr    clrin        ;set up instack
  47.     lea    bufflgs,a0
  48.     clr.l    (a0)
  49.     clr.l    4(a0)        ;clear 8 byte flags
  50.     lea    lstkptr,a0    ;link ptrs
  51.     move.l    a0,(a0)
  52.     lea    lpstkptr,a0    ;loop ptrs
  53.     move.l    a0,(a0)        ;clear system stacks
  54.     lea    oldlen,a0
  55.     clr.l    (a0)        ;no previous keyboard input
  56.     rts
  57. ;
  58. headersup:
  59.     move.l    2(a5),a1    ;code size
  60.     lea    cp,a0
  61.     move.l    a1,(a0)        ;cp offset
  62.     lea    fence,a0
  63.     move.l    a1,(a0)
  64.     adda.l    a5,a1        ;address of headers before move
  65. ;
  66.     lea    stack,a0
  67.     move.l    (a0),a0        ;base of return stack
  68.     move.l    a0,d0
  69.     sub.l    a5,d0        ;offset of stack base
  70.     add.l    6(a5),d0    ;add header size to point to top
  71. ;
  72.     lea    hp,a2
  73.     move.l    d0,(a2)        ;headers to go to stack base
  74.     move.l    6(a5),d0    ;get length of header block (data)
  75.     movem.l d0/a0/a1,-(a6)
  76.     bsr    _cmove        ;move all headers up
  77.     bsr    _there
  78.     lea    entry,a0
  79.     pop    (a0)        ;entry has a real address (not offset)
  80.     rts
  81. ;
  82. endup:    clr.w    -(a7)
  83.     move.w    #$4c,-(a7)
  84.     trap    #1        ;p_term
  85. ;
  86.